﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="../../function.js"></script>
<title>FindXmlKey 查找XML中指定节点值</title>
<style>
body{font-size:12px; font-family:Verdana,"宋体"}
.ts{ background:#fff; margin:0 0 40px 0;}
.ts th{ color:#7B797B; background:#DEDFDE; line-height:24px;}
.ts td {padding:6px 0;}
.name { font-size:16px; font-weight:bold; border-top:1px dashed #9C9A9C; border-bottom:1px dashed #9C9A9C; color:#316AC5;}
.canshu { background:#E7E7EF;}
.red{ color:#d60000;}
.green{ color:#006939;}
.blue{ color:#316AC5;}
.yufa{ border-top:1px dashed #9C9A9C;color:#316AC5;}
.fanhui{ border-bottom:1px dashed #9C9A9C;}
.lizi{ border-bottom:1px dashed #9C9A9C;}
.beizhu{ border-bottom:1px dashed #9C9A9C;}
</style></head><body>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="ts">
<tr><th width="100">命令名称：</th><td class="name">
<a name="Delay"></a>FindXmlKey
</td></tr><tr><th>命令功能：</th><td>
根据指定的key和val的内容来查找指定的key的内容
</td></tr><tr><th>参数说明：</th><td class="canshu"><pre>参数1【必要】：字符串，GetUIXml()命令获取到的XML字符串
参数2【必要】：字符串，查找条件的节点名
参数3【必要】：字符串，查找条件节点名对应的值
参数4【必要】：字符串，要查找的节点名
</pre>
</td></tr><tr><th>返回值：</th><td class="fanhui">
返回字符串，返回第一个找到的结果
</td></tr><tr><th><span class="red">脚本例子：</span>
</th><td class="lizi"><PRE id="code">  
Import "ShanHai.lua"
 
Dim XML = shanhai.GetUIXml()
' 查找text内容为“VIP专享”的坐标
' bounds这个key是用来存放界面元素里的坐标范围
dim tmpPonit =  shanhai.FindXmlKey(XML, "text", "VIP专享", "bounds")
Dim PonitArr = GetPonit(tmpPonit)
TracePrint "VIP专享的坐标是：" &amp; PonitArr(0) &amp; ", " &amp; PonitArr(1)


' 提取坐标中心点
Function GetPonit(sPoint)
	Dim tmp
	tmp = Array()
	dim RegexArr = shanhai.RegexFindEx(sPoint, "%[(%d+),(%d+)%]%[(%d+),(%d+)%]")
	For i = 0 To UBOUND(RegexArr(0))
		tmp[i+1] = RegexArr(0, i)
	Next
	GetPonit = array(tmp[1], tmp[2])
End Function
</PRE><script type="text/javascript" src="../../write.js"></script>
</td></tr></table>
</body>
</html>